define(function(require){
	var $ = require("jquery");
	var justep = require("$UI/system/lib/justep");
	var service = require('../js/service');
	
	var Model = function(){
		this.callParent();
	};

	Model.prototype.registerBtnClick = function(event){
		justep.Shell.showPage('register');
	};

	Model.prototype.loginBtnClick = function(event){
		var name = this.comp("loginNameInput").val();
		var pswd = this.comp("loginPswdInput").val();
		
		// TODO 这里应该监测name，pswd
		if (false) {
			justep.Util.hint('登录信息有误');
		}
		
		// 提交注册
		service.login(name, pswd,
			function(res){
				justep.Util.hint('登录成功');
				// TODO 进入列表页
				justep.Shell.showPage('list');
			},
			function() {
				justep.Util.hint('登录失败，请重试');
			}
		);

	};

	return Model;
});